package loader

import (
	"os"
	"kumachan/standalone/util/richtext"
	"kumachan/interpreter/lang/common/source"
)


type context struct {
	ImportPoint  source.Location  // nullable
	ImportName   string
	BreadCrumbs  [] ancestor
}
type ancestor struct {
	ModuleName  string
	FileInfo    os.FileInfo
	FilePath    string
}
func makeEntryContext() context {
	return context {
		ImportPoint: source.Location {},
		BreadCrumbs: make([] ancestor, 0),
	}
}
func (ctx context) WrapErrorBlock(desc richtext.Block) richtext.Block {
	if ctx.ImportPoint != (source.Location {}) {
		var b richtext.Block
		b.WriteSpan("Unable to import dependency", richtext.TAG_ERR_NORMAL)
		b.WriteSpan(ctx.ImportName, richtext.TAG_ERR_INLINE)
		b.WriteSpan("from", richtext.TAG_ERR_NORMAL)
		b.WriteSpan(ctx.ImportPoint.FilePath(), richtext.TAG_ERR_INLINE)
		b.Append(desc)
		return b
	} else {
		return desc
	}
}

func manifestDepPos(index uint32) source.Position {
	return source.Position { Index1: index }
}
type manifestSourceFile struct {
	FilePath  string
}
func (sf manifestSourceFile) GetPath() string {
	return sf.FilePath
}
func (sf manifestSourceFile) DescribePosition(_ source.Position) string {
	return ""
}
func (sf manifestSourceFile) FormatMessage(_ source.Position, desc richtext.Block) richtext.Block {
	return desc
}


